/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.model.admin;

import com.admin.sessionbeancontroller.AdminFacadeLocal;
import com.entities.Admin;
import javax.ejb.EJB;
import javax.ejb.Stateful;

/**
 *
 * @author Tuan Long
 */
@Stateful
public class LoginModel implements LoginModelRemote {

    @EJB
    private AdminFacadeLocal adminFacade;

    @Override
    public String loginControl(String username, String password) {
        Admin a = adminFacade.find(username);
        if (a != null) {
            if (a.getPassword().contains(password)) {
                return a.getFullname();
            } else {
                return null;
            }
        }
        return null;
    }

    @Override
    public void test(String name) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

}
